import Vue from 'vue'
import VueRouter from 'vue-router'
import Main from '../views/Main'
import home from '../views/home'
import login from '../views/login'
import problemInput from '../views/admin/problem/InputView'
import collection from '../views/problem/collection'
import collectionManage from '../views/admin/problem/collection'
import Admin from '../views/admin'
import guestCode from '../views/guest/code'
import guest from '../views/guest'
import hostView from '../views/host'
import problemManage from '../views/admin/problem/promanage'
import Detail from '../views/admin/problem/detail'
import User from '../views/admin/user'

Vue.use(VueRouter)

//这里一定要是routes
const routes = [
    {
        //首页面
        path: '/',
        name: 'chocho',
        redirect: '/host',
        component: hostView
    },
    {
        path: '/',
        name: 'Main',
        //按需引入
        component: Main,
        //入口路由
        //
        children:[
            {
                //首页面
                path: 'host',
                name: 'host',
                component: hostView
            },
            {
                //做题页面
                path: 'problem',
                name: 'problem',
                component: home
            },
            {
                //展示题目集页面
                path: 'collection',
                name: 'collection',
                component: collection
            },
            {
                //管理员/教师端
                path: 'admin',
                name: 'admin',
                component: Admin,
                children: [
                    {
                        //题目输入页面
                        path: 'problem/input',
                        name: 'problem-input',
                        component: problemInput
                    },
                    {
                        //题目集管理页面
                        path: 'problem/collection',
                        name: 'collection-manage',
                        component: collectionManage
                    },
                    {
                        //题目管理页面
                        path: 'problem/manage',
                        name: 'problem-manage',
                        component: problemManage
                    },
                    {
                        //题目详情页面
                        path: 'problem/detail',
                        name: 'problem-detail',
                        component: Detail,
                    },
                    {
                        //用户管理页面
                        path: 'user',
                        name: 'user',
                        component: User,
                    }
                ]
            },
            {
                //游客页面
                path: 'guest',
                name: 'guest',
                component: guest,
                children: [
                    {
                        //提交代码页面
                        path: 'code',
                        name: 'code',
                        component: guestCode
                    }
                ]
            }
        ]
    },
    {
        //登录页面
        path: '/login',
        name: 'login',
        component: login
    }
]

const router = new VueRouter({
    mode: 'history',
    routes
})

export default router